import 'dart:io';

import 'package:image_picker/image_picker.dart';

class ImagePickerUtils {
  static int camera = 0;
  static int gallery = 1;

  static Future<File?> pickImage(int source,
      {double? maxWidth, double? maxHeight, int? imageQuality}) async  {
    // var sources = ImageSource.camera;
    // if (source == camera) {
    //    sources = ImageSource.camera;
    // } else if (source == gallery) {
    //    sources = ImageSource.gallery;
    // }
    final imageSource=source==camera?ImageSource.camera:ImageSource.gallery;
    final file=await (ImagePicker.platform.pickImage(
      source: imageSource,
      preferredCameraDevice: CameraDevice.rear
      // maxWidth: maxWidth,
      // maxHeight: maxHeight,
      // imageQuality: imageQuality
    ) );

    if(file==null) return null;
    return File(file.path);
  }
  static Future<File?> pickVideo(int source,) async  {
    final imageSource=source==camera?ImageSource.camera:ImageSource.gallery;
    final file=await (ImagePicker.platform.pickVideo(source: imageSource) );
    if(file==null) return null;
    return File(file.path);
  }
  static Future<List<PickedFile>?> pickMultiImage() async  {
    final file=await (ImagePicker.platform.pickMultiImage());
    if(file==null) return null;
    return file;
  }
}
